function initWangEditor(param) {

  if (typeof param.editorElem == "undefined") {
    return false;
  }
  if (typeof param.uploadImgServer == "undefined") {
    param.uploadImgServer = window.uploadAddressPrefix + 'File/wangEditorSave'
  }
  if (typeof param.uploadImgUrlServer == "undefined") {
    param.uploadImgUrlServer = window.uploadAddressPrefix + 'File/urlSave'
  }
  if (typeof param.uploadImgBase64Server == "undefined") {
    param.uploadImgBase64Server = window.uploadAddressPrefix + 'File/base64Save'
  }
  if (typeof param.uploadImgType == "undefined") {
    param.uploadImgType = 'post_img'
  }
  if (typeof param.height == "undefined") {
    param.height = window.innerHeight * 0.75
  }
  if (typeof param.menus == "undefined") {
    param.menus = [
      'head',
      'bold',
      'fontSize',
      'fontName',
      'italic',
      'underline',
      'strikeThrough',
      'indent',
      'lineHeight',
      'foreColor',
      'backColor',
      'link',
      'list',
      'justify',
      'quote',
      'emoticon',
      'image',
      'video',
      'table',
      'code',
      'splitLine',
      'undo',
      'redo',
    ]
  }
  if (typeof param.layer != "undefined") {
    var layer = param.layer
  } else {
    var layer = window.layer
  }

  const E = window.wangEditor
  const editor = new E(param.editorElem)
  editor.config.menus = param.menus
  editor.config.showFullScreen = false
  editor.config.height = param.height
  editor.config.pasteFilterStyle = true
  editor.config.uploadImgServer = param.uploadImgServer
  editor.config.uploadFileName = 'File_'
  editor.config.uploadImgParams = {
    type: param.uploadImgType
  }
  editor.config.uploadImgMaxSize = '10485760'
  editor.config.uploadImgAccept = ['jpg', 'jpeg', 'png', 'gif', 'bmp']

  editor.config.pasteTextHandle = function (pasteStr) {

    layer.load();

    //1，匹配出图片img标签（即匹配出所有图片），过滤其他不需要的字符
    //2.从匹配出来的结果（img标签中）循环匹配出图片地址（即src属性）

    //匹配图片（g表示匹配所有结果i表示区分大小写）
    var imgReg = /<img.*?(?:>|\/>)/gi;
    //匹配src属性
    var srcReg = /src=[\'\"]?([^\'\"]*)[\'\"]?/i;
    var arr = pasteStr.match(imgReg);

    for (var i = 0; i < arr.length; i++) {
      var src = arr[i].match(srcReg);
      //获取图片地址
      if (src[1]) {
        var imgSrc = src[1];
        var prefix = imgSrc.substr(0, 4);
        if (prefix == 'http') {
          $.ajax({
            async: false,
            type: 'POST',
            url: param.uploadImgUrlServer,
            data: {
              url: imgSrc,
              type: param.uploadImgType
            },
            success: function (result) {
              pasteStr = pasteStr.replace(imgSrc, result.data.src)
            }
          })
        } else if (prefix == 'data') {

          $.ajax({
            async: false,
            type: 'POST',
            url: param.uploadImgBase64Server,
            data: {
              data: imgSrc,
              type: param.uploadImgType
            },
            success: function (result) {
              pasteStr = pasteStr.replace(imgSrc, result.data.src)
            }
          })
        }
      }
    }
    layer.closeAll('loading')

    return pasteStr
  }
  editor.create()

  return editor
}

function sendRecord(post) {
  $.post('/Record/save', post)
}